<!DOCTYPE html>
<html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <head th:include="commom::title('申请医疗')"></head>
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layui-form-pane">
    <div class="layui-form-item" >
        <label class="layui-form-label required">医疗名称</label>
        <div class="layui-input-block">
            <input type="text" disabled name="proname" lay-verify="required"  th:value="${applyFood.proname}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" >
        <label class="layui-form-label required" >价格</label>
        <div class="layui-input-block">
            <input type="text" disabled name="cost" lay-verify="required"  th:value="${applyFood.cost}" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" >
        <label class="layui-form-label required">预约服务时间</label>
        <div class="layui-input-block">
            <input type="datetime-local" name="starttime" lay-verify="required" placeholder="请输入日期" th:value="${applyFood.starttime}" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block" >
            <button class="layui-btn layui-btn-normal" style="width: 80%"  lay-submit lay-filter="altBtn">确认申请</button>
        </div>
    </div>
    <div class="layui-form-item" >
        <div class="layui-input-block">
            <input type="hidden" name="uid" lay-verify="required"  th:value="${applyFood.uid}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" >
        <div class="layui-input-block">
            <input type="hidden" name="user" lay-verify="required"  th:value="${applyFood.user}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" >
        <div class="layui-input-block">
            <input type="hidden" name="sort" lay-verify="required"  th:value="${applyFood.sort}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" >
        <div class="layui-input-block">
            <input type="hidden" name="status" lay-verify="required"  th:value="${applyFood.status}" class="layui-input">
        </div>
    </div>
</div>
<script th:src="@{/static/lib/layui-v2.5.5/layui.js}" charset="utf-8"></script>
<script>
    layui.use(['form','layer'], function () {
        const form = layui.form,
            layer = layui.layer,
            $ = layui.$;
        form.on('submit(altBtn)', function (data) {
            console.log(data.field)
            $.ajax({
                url:'/root/addapplyfood',
                data:data.field,
                dataType:'json',
                type:'post',
                success:function (data) {
                    if (data.code==200){
                        layer.msg(data.msg,{icon:1});
                    }else{
                        layer.msg(data.msg,{icon:2});
                    }
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        window.parent.location.reload();
                    }, 1000);
                }
            })
            return false;
        });

    });
</script>
</body>
</html>
